package top.hundreds.oasys.bean.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum FileType {
    PNG(0, "png"),
    JPG(1, "jpg"),
    JPEG(2, "jpeg"),
    DOC(3, "doc"),
    DOCX(4, "docx"),
    XLS(5, "xls"),
    XLSX(6, "xlsx"),
    PPT(7, "ppt"),
    PPTX(8, "pptx"),
    RAR(9, "rar"),
    ZIP(10, "zip"),
    _7Z(11, "7z");

    @JsonValue
    @EnumValue
    private final Integer value;

    private final String label;

    public static FileType formValue(Object o) {
        if (o != null) {
            for (FileType fileType : values()) {
                if (fileType.getValue().equals(o)) {
                    return fileType;
                }
            }
        }
        return null;
    }

    public static FileType formLabel(Object o) {
        if (o != null) {
            for (FileType fileType : values()) {
                if (fileType.getLabel().equals(o)) {
                    return fileType;
                }
            }
        }
        return null;
    }
}
